<?php

namespace App\Admin\Controllers\Permission;

use App\Extends\BaseController;
use App\Services\Permission\LogsService;
use Illuminate\Http\Request;

class LogsController extends BaseController
{
    public function __construct(LogsService $service)
    {
        parent::__construct($service);
        $this->service = $service;
    }

    /**
     * 显示资源列表
     * @return \Illuminate\Http\JsonResponse
     */
    public function index(Request $request): \Illuminate\Http\JsonResponse
    {
        $where = [
            ['admin_name', 'like', '%' . $request->get('admin_name') . '%'],
        ];
        return $this->paginate($this->service->paginate($where));
    }

    /**+
     * 显示指定资源
     *
     * @param $id
     * @return \Illuminate\Http\JsonResponse
     */
    public function show($id): \Illuminate\Http\JsonResponse
    {
        return $this->success($this->service->find($id));
    }

    /**
     * 删除指定资源
     * @param $id
     * @return \Illuminate\Http\JsonResponse
     */
    public function destroy($id): \Illuminate\Http\JsonResponse
    {
        return $this->success($this->service->delete($id));
    }
}
